package com.blog.web.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blog.common.domain.entity.PhotoAlbum;
import com.blog.common.domain.vo.PhotoAlbumVo;
import com.blog.common.domain.enums.ArticleEnums;
import com.blog.common.mapper.dao.PhotoAlbumMapper;
import com.blog.web.service.PhotoAlbumService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 相册 服务实现类
 * </p>
 *
 * @author Valerie
 * @since 2023-02-18
 */
@Service
public class PhotoAlbumServiceImpl extends ServiceImpl<PhotoAlbumMapper, PhotoAlbum> implements PhotoAlbumService {

    @Resource
    private PhotoAlbumMapper photoAlbumMapper;

    @Override
    public List<PhotoAlbumVo> listPhotoAlbums() {
        List<PhotoAlbum> photoAlbumList = photoAlbumMapper.selectList(
                new LambdaQueryWrapper<PhotoAlbum>()
                        .orderByDesc(PhotoAlbum::getIsTop)
                        .orderByDesc(PhotoAlbum::getId)
        );
        return BeanUtil.copyToList(photoAlbumList, PhotoAlbumVo.class);
    }
}
